﻿using Guild_Wars_2.Common;
using Guild_Wars_2.Data;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Serialization;
using Windows.ApplicationModel;
using Windows.ApplicationModel.DataTransfer;
using Windows.ApplicationModel.Resources;
using Windows.Data.Xml.Dom;
using Windows.Storage;
using Windows.Storage.Streams;
using Windows.UI.Notifications;
using Windows.Web.Syndication;

namespace FantasyWereld.Code
{
    class Utility
    {
        public static async Task<XmlDocument> ReadXMLDocumentFromFileAsync(string fileName)
        {
            try
            {
                // Determine source folder location
                StorageFolder sourceFolder = ApplicationData.Current.LocalFolder;

                // Determine source filename
                StorageFile sourceFilename = await sourceFolder.GetFileAsync(fileName);

                XmlLoadSettings loadSettings = new XmlLoadSettings();
                loadSettings.ProhibitDtd = false;
                loadSettings.ResolveExternals = false;

                return await XmlDocument.LoadFromFileAsync(sourceFilename, loadSettings);
            }
            catch
            {
                return null;
            }
        }
    }
}
